package com.bawei.liuzhanlin20210806.view.activity;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.bawei.liuzhanlin20210806.presenter.BasePresenter;
import com.bawei.liuzhanlin20210806.view.interfaces.BaseView;

/**
 * Time: 2021/8/6
 * Author:liuzhanlin
 * Description:zhuangao6
 */
public abstract class BaseActivity<P extends BasePresenter> extends AppCompatActivity implements BaseView {
    private P presenter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getlayout());
        initview();
        presenter = initpresenter();
        presenter.acesView(this);
        initdata();
    }

    public P getPresenter() {
        return presenter;
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (presenter!=null){
            presenter.caseView();
        }
    }

    public abstract int getlayout();
    public abstract void initview();
    public abstract P initpresenter();
    public abstract void initdata();
}
